package src.com.foreknow.demo10;

/**
 * 构造器的重载
 * 注意：如果一个类中定义了一个或多个有参数的构造器，那么一定要提供一个无参的构造器（方便使用set，get方法）
 */

public class Employee {
    private String name;
    private int age;
    private String dept;

    public Employee(){

    }
    public Employee(String name,int age){
        this.name = name;
        this.age = age;
    }
    public Employee(String name,int age,String dept){
        this.name = name;
        this.age = age;
        this.dept = dept;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getDept() {
        return dept;
    }

    public void setDept(String dept) {
        this.dept = dept;
    }

    public static void main(String[] args) {
        Employee employee2 = new Employee();
        employee2.setName("jack");
        System.out.println(employee2.getName());
        Employee employee = new Employee("fender",12);
        System.out.println(employee.getName()+"---"+employee.getAge());
        Employee employee1 = new Employee("tom",31,"clean");
        System.out.println(employee1.getName()+"---"+employee1.getAge()+"---"+employee1.getDept());

    }
}

























